#include <bits/stdc++.h>

using namespace std;

long long tc = 1, n, m, l, V, ans1, ans2;
long long d[114514], v[114514], a[114514], p[114514];
long long b[3005][3005], cnt[3005];

void init() {
    ans2 = 0;
    ans1 = 0;
    for (long long i = 1; i <= n; i++) {
        cnt[i] = 0;
        for (long long j = 1; j <= m; j++) {
            b[i][j] = 0;
        }
    }
}

void slv() {
    for (long long i = 1; i <= n; i++) {
        scanf("%lld %lld %lld", &d[i], &v[i], &a[i]);
    }
    for (long long i = 1; i <= m; i++) {
        scanf("%lld", &p[i]);
    }
    for (long long i = 1; i <= n; i++) {
        bool ok = 0;
        for (long long j = 1; j <= m; j++) {
            if (d[i] <= p[j]) {
                long double D = sqrt(max((long double)0, (long double)(v[i] * v[i]) + 2.0000000 * (long double)a[i] * (long double)(p[j] - d[i])));
                if (D > (long double)V) {
                    b[i][j] = 1;
                    cnt[i]++;
                    ok = 1;
                }
            }
        }
        if (ok) {
            ans1++;
        }
    }
    printf("%lld ", ans1);
    for (long long i = 1; i <= m; i++) {
        bool ok = 1;
        for (long long j = 1; j <= n; j++) {
            if (cnt[j] == 1 && b[j][i]) {
                ok = 0;
            }
        }
        if (ok) {
            for (long long j = 1; j <= n; j++) {
                if (b[j][i]) {
                    b[j][i] = 0;
                    cnt[j]--;
                }
            }
            ans2++;
        }
    }
    printf("%lld\n", ans2);
}

int main() {

    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);

    scanf("%lld", &tc);
    while (tc--) {
        scanf("%lld %lld %lld %lld", &n, &m, &l, &V);
        init();
        slv();
    }

    return 0;
}
